#ifndef BUDDYCHANGEDEVENT_H_
#define BUDDYCHANGEDEVENT_H_

#include <wx/event.h>
#include "../Buddy.h"

namespace Impp
{

enum BuddyChangedEventType{
	BUDDY_CHANGED_ADDED,
	BUDDY_CHANGED_CUSTOMNAME,
	BUDDY_CHANGED_GROUP,
	BUDDY_CHANGED_PRIVACY_LIST,
	BUDDY_CHANGED_PRIORITY,
	BUDDY_CHANGED_AUTHORISATION,
	BUDDY_CHANGED_FULL_USERINFO
};

class BuddyChangedEvent : public wxNotifyEvent
{
private:
	Buddy* buddy;
	BuddyChangedEventType changeType;
	Group* oldGroup;
	Group* newGroup;
	wxString oldCustomName;
	wxString newCustomName;

public:
	BuddyChangedEvent(Buddy* buddy, BuddyChangedEventType changeType, wxEventType eventType = wxEVT_NULL, int id = 0);
	virtual ~BuddyChangedEvent();

	virtual wxEvent* Clone()const;
	Buddy* getBuddy();
	Group* getOldGroup();
	Group* getNewGroup();
	wxString getOldCustomName();
	wxString getNewCustomName();
	BuddyChangedEventType getChangeType();

private:
	friend class Impp;
	void setOldGroup(Group* group);
	void setNewGroup(Group* group);
	void setOldCustomName(const wxString & oldCustomName);
	void setNewCustomName(const wxString & newCustomName);

};

typedef void(wxEvtHandler::*BuddyChangedEventFunction)(BuddyChangedEvent&);

BEGIN_DECLARE_EVENT_TYPES()
  DECLARE_EVENT_TYPE(EVT_BUDDY_CHANGED, -1)
END_DECLARE_EVENT_TYPES()

#define EVT_BUDDY_CHANGED_MACRO(id, fn) DECLARE_EVENT_TABLE_ENTRY(               \
	EVT_BUDDY_CHANGED, id, -1, (wxObjectEventFunction)               \
        (wxEventFunction)(BuddyChangedEventFunction) & fn,                             \
        (wxObject*) NULL),

#define BuddyChangedEventHandler(func)                                                 \
        (wxObjectEventFunction)                                                \
        (wxEventFunction)wxStaticCastEvent(BuddyChangedEventFunction, &func)


}

#endif /*BUDDYCHANGEDEVENT_H_*/
